import java.io.DataInputStream;
import java.io.IOException;
import java.net.Socket;

public class ServerSocketThread extends Thread {

    private Socket socket;

    public ServerSocketThread(Socket socket) {
        this.socket = socket;
        System.out.println("有人上线了：" + socket.getRemoteSocketAddress());
    }

    @Override
    public void run() {
        try {
            // 获取输入流
            DataInputStream dis = /* TODO */
            while (true) {
                // 读取数据
                String data = /* TODO */

                // 如果客户端发过来的数据是exit，则跳出循环
                if (/* TODO */) {
                    break;
                }
                System.out.println(data);
            }
            dis.close();
            socket.close();
            System.out.println("有人下线了：" + socket.getRemoteSocketAddress());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
